while True:
    try:
        # n = int(input())
        n = 3
        arr = []
        order = []
        res = 0
        # for i in range(n):
        #     arr.append(list(map(int,input().split())))
        # f = input()
        arr = [[50, 10], [10, 20], [20, 5]]
        # print(arr)
        # print(f)
        f= "(A(BC))"
        for i in f:
            if i.isalpha():
                order.append(arr[ord(i)-65])
            elif i == ")" and len(order)>=2:
                b = order.pop()
                a = order.pop()
                res += a[1]*b[1]*a[0]
                order.append([a[0],b[1]])
        print(res)
    except:
        break